package sy.mail.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import sy.mail.model.Mail;


/**
 * <Title></Title> 
 *
 * <Author>线程池</Author>
 *
 * <Copyright>Copyright (c) 2012</Copyright>
 *
 * <Create Date>Jul 27, 2012,9:15:53 AM</Create Date>
 *
 * <Version>1.0</Version> 
 */
public class ThreadPool {
	
	
	public static void main(String[] args){
		
		
		ExecutorService pool = Executors.newFixedThreadPool(5);
		// 创建实现了Runnable接口对象，Thread对象当然也实现了Runnable接口
		Mail mail = new Mail();
		Mail mail1 = new Mail();
		for(int i = 0;i<3;i++){
			mail.addAddress("371351694@qq.com");
			mail1.addAddress("371351694@qq.com");
		}
		MailThread t1 = new MailThread(mail);
		MailThread t2 = new MailThread(mail1);
		// 将线程放入池中进行执行
		pool.execute(t1);
		pool.execute(t2);
		// 关闭线程池
		pool.shutdown();
	}
}
